package com.oo.array_$.case_2;

import java.util.Scanner;

/**
 * CalcDemo--编写JAVA程序，实现接收用户输入的8个整数，
 * 输出最大值，最小值和平均值
 要求：通过循环方式，查询数组中最大值和最小值
 *
 * @author: Jovi
 * @createTime: 2017-05-11 16:14
 **/
public class CalcDemo {
    public static void main(String[] args) {
        int max,min,sum=0;
        int[] a = new int[8];
        Scanner sc = new Scanner(System.in);
        System.out.println("Please input in turn eight integer：");
        for (int i = 0; i < a.length; i++) {

            a[i] = sc.nextInt();
            sum += a[i];
        }
        System.out.println("=====================");
        max=min=a[0];
        for (int i = 0; i < a.length; i++) {
            if (a[i] > max) {
                max = a[i];
            }
            if (a[i] < min) {
                min = a[i];
            }
        }
        System.out.println("the max is：" + max);
        System.out.println("the min is：" + min);
        System.out.println("the avg is：" + sum / 8);
    }
}
